package com.huangxt.test.stock;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.collections.list.SynchronizedList;

import static com.huangxt.test.stock.StockConstance.*;
import java.math.BigDecimal;
import java.math.RoundingMode;

@Getter
@Setter
@AllArgsConstructor
public class Stock extends Thread{

    private int userId ;
    private BigDecimal assets;
    public void multipy(BigDecimal bigDecimal){
        this.assets = this.assets.multiply(bigDecimal);
    }

    public static void main(String[] args) {
        BigDecimal bigDecimal =new BigDecimal("10000");
        System.out.println("用户|金额");
        for (int i=0;i<1000;i++){
            Stock stock = new Stock(i,bigDecimal);
            stock.start();
        }
    }

    @Override
    public void run() {
        for (int i = 0; i < 5000; i++) {
            this.multipy((int) (Math.random() * 2) >0?(this.assets.compareTo(new BigDecimal(10000*100))>0?OVERUPPER:UPPER):LOWER);
        }
        System.out.println("用户"+userId+"|"+assets.setScale(10, RoundingMode.FLOOR).toString());
    }
}
